import { HashMap } from "../../api/struct/HashMap";
import { CDShopGood } from "../excel/CDShopGood";



/**
 * 扩展-商城商品
 */
export abstract class CEShopGood {

    /**类型分组商品<shopId, > */
    public static readonly shopGoodGroup = new HashMap<number, HashMap<number, CDShopGood[]>>();

    /**初始化 */
    public static init(): void {
        const map = this.shopGoodGroup;
        const vs = CDShopGood.datas.getValues();

        for (let i = 0, len = vs.length; i < len; i++) {
            const config = vs[i];

            let typeMap = map.get(config.shopId);
            if (!typeMap) {
                typeMap = new HashMap<number, CDShopGood[]>();
                map.put(config.shopId, typeMap);
            }

            let groupList = typeMap.get(config.group);
            if (!groupList) {
                groupList = [];
                typeMap.put(config.group, groupList);
            }

            groupList.push(config);
        }
    }
}